package snippet;
import java.util.*;
public class 非递减子序列 {
	List<List<Integer>> result = new ArrayList<>();
	List<Integer> item = new ArrayList<>();
    public List<List<Integer>> findSubsequences(int[] nums) {
    	backtracking(nums, 0);
    	System.out.println(result);
    	return result;
    }
    
    public void backtracking(int nums[], int index) {
    	if(item.size() >= 2) {
    		result.add(new ArrayList<>(item));
    	}
    	Map<Integer,Integer> map = new HashMap<>();
    	for(int i = index; i < nums.length; i++) {
    		if(item.size() > 0 &&  nums[i] < item.get(item.size()-1)) {
    			continue;
    		}
    		if(map.get(nums[i]) != null) {
    			continue;
    		}
    		map.put(nums[i], 1);
    		item.add(nums[i]);
    		backtracking(nums, i + 1);
    		item.remove(item.size() - 1);
    	}
    	
    }
    
    public static void main(String[] args) {
		int nums[] = {4,6,7,7};
		new 非递减子序列().findSubsequences(nums);
	}
}
